package id.net.iconpln.bb.client.view;

import id.net.iconpln.bb.client.service.PortRPCService;
import id.net.iconpln.bb.client.service.PortRPCServiceAsync;
import id.net.iconpln.bb.client.util.ClientModule;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.Orientation;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.binding.FormBinding;
import com.extjs.gxt.ui.client.core.FastMap;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.widget.ContentPanel;
import com.extjs.gxt.ui.client.widget.Info;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.ComboBox;
import com.extjs.gxt.ui.client.widget.form.ComboBox.TriggerAction;
import com.extjs.gxt.ui.client.widget.form.DateField;
import com.extjs.gxt.ui.client.widget.form.DateTimePropertyEditor;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.layout.FitData;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FormData;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.extjs.gxt.ui.client.widget.layout.RowData;
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
import com.extjs.gxt.ui.client.widget.toolbar.LabelToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class PageBbPortKedatangan extends LayoutContainer {
	private final PortRPCServiceAsync service = GWT.create(PortRPCService.class);
	private FormBinding formBindings;  
	private FormData formData; 
	private ListStore storeKplKirim,storeKplAntri, storeJetty;
	private Grid gridKplKirim, gridKplAntri;
	private ComboBox cboJetty;
	private DateField tglTa, tglTd;
	private TextField<String> noAntri;
	private Button bSubmit;
	
	  @Override  
	  protected void onRender(Element parent, int index) {  
	    super.onRender(parent, index);  
	    setLayout(new FitLayout());
	    initStore();
	    
	    formData = new FormData("-20"); 
	    ContentPanel cp = new ContentPanel();  
	   
	    cp.setHeaderVisible(false);
	    cp.setFrame(true);  
	    cp.setSize(900, 400);  
	    cp.setLayout(new RowLayout(Orientation.HORIZONTAL)); 
//	    cp.setLayout(new RowLayout(Orientation.VERTICAL));	  
	  
	    gridKplKirim = createGridKirim();  
	    gridKplKirim.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplKirim.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<BaseModel>>() {  
	          public void handleEvent(SelectionChangedEvent<BaseModel> be) {
	        	  noAntri.setVisible(false);	 
	        	  bSubmit.setEnabled(true);
	            if (be.getSelection().size() > 0) {  	              
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbJadwal = new ToolBar();
	    tbJadwal.add(new LabelToolItem("<b>Data Kedatangan Kapal</b>"));
	    tbJadwal.add(new SeparatorToolItem());
	    
	    aktivitasDermaga("pengiriman","PENGIRIMANPORTBYALLPEMASOK", "","");
	    aktivitasDermaga("master","JETTY","", "");
	    aktivitasDermaga("antri","KEDATANGAN","", "");
	    
	    gridKplAntri = createGridAntri();
	    gridKplAntri.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);  
	    gridKplAntri.getSelectionModel().addListener(Events.SelectionChange,  
	        new Listener<SelectionChangedEvent<BaseModel>>() {  
	          public void handleEvent(SelectionChangedEvent<BaseModel> be) {
	        	  noAntri.setVisible(true);
	        	  bSubmit.setEnabled(false);
	            if (be.getSelection().size() > 0) {  	               		
	              formBindings.bind((ModelData) be.getSelection().get(0));  
	            } else {  
	              formBindings.unbind();  
	            }  
	          }  
	        });
	    ToolBar tbPltu = new ToolBar();
	    tbPltu.add(new LabelToolItem("<b>Data Kapal Antri</b>"));
	    tbPltu.add(new SeparatorToolItem());
	    	    
//	    gridship = createGridPreshipment();
//	    ToolBar tbShip = new ToolBar();
//	    tbShip.add(new LabelToolItem("<b>Data Pemasok</b>"));
//	    tbShip.add(new SeparatorToolItem());
	    

	    FormPanel panel = createForm(); 
	    panel.setScrollMode(Scroll.AUTO);
	    formBindings = new FormBinding(panel, true);  
//	    formBindings.setStore((Store) grid.getStore());  
	    
	    
	    ContentPanel pKplKirim = new ContentPanel();
	    pKplKirim.setHeaderVisible(false);
//	    pKplKirim.setLayout(new FitLayout());
	    pKplKirim.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplKirim.add(gridKplKirim,new RowData(1, 1));
	    pKplKirim.setTopComponent(tbJadwal);

	    ContentPanel pKplAntri = new ContentPanel();
	    pKplAntri.setHeaderVisible(false);
	    pKplAntri.setLayout(new RowLayout(Orientation.HORIZONTAL));
	    pKplAntri.add(gridKplAntri,new RowData(1, 1));
	    pKplAntri.setTopComponent(tbPltu);

	    
	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);
	    p.setLayout(new RowLayout(Orientation.VERTICAL));	    	    
	    p.add(pKplKirim, new RowData(.99, .5));
	    p.add(pKplAntri, new RowData(.99, .5));
//	    p.setTopComponent(tbPltu);

	    
	    cp.add(panel, new RowData(.4, 1));
	    cp.add(p, new RowData(.6, 1));
	    
	    
//		setScrollMode(Scroll.AUTO);		
	    add(cp, new FitData(5));  
	  }  
	  
	  private void initStore(){
		  storeKplKirim = new ListStore(); 
		  storeKplAntri = new ListStore(); 
		  storeJetty = new ListStore();
	  }

	  
	  private FormPanel createForm() {  
	    FormPanel panel = new FormPanel();	    
	    panel.setHeaderVisible(false);
	    
	    FieldSet fieldSet = new FieldSet();  
	    fieldSet.setHeading("Informasi Kedatangan");  
	    fieldSet.setCollapsible(false);
	    
	  
	    FormLayout layout = new FormLayout();  
	    layout.setLabelWidth(180);  
	    fieldSet.setLayout(layout);  

	    noAntri = new TextField<String>();  
	    noAntri.setName("no_kedatangan");  
	    noAntri.setFieldLabel("No Antri");    
//	    noAntri.setVisible(false);
	    fieldSet.add(noAntri, formData);	
	    
	    
	    final TextField<String> noPengiriman = new TextField<String>();  
	    noPengiriman.setName("no_pengiriman");
	    noPengiriman.setValidateOnBlur(true);
	    noPengiriman.setFieldLabel("No Pengiriman");    
	    fieldSet.add(noPengiriman, formData);	  	  

	    final TextField<String> idPengiriman = new TextField<String>();  
	    idPengiriman.setName("id_pengiriman");
	    idPengiriman.setVisible(false);
	    idPengiriman.setFieldLabel("id_pengiriman");    
	    fieldSet.add(idPengiriman, formData);	  	  
	    	     

	    final TextField<String> noJadwal = new TextField<String>();	    
	    noJadwal.setName("no_jadwal"); 
	    noJadwal.setValidateOnBlur(true);
	    noJadwal.setFieldLabel("No Jadwal");    
	    fieldSet.add(noJadwal, formData);

	    TextField<String> pemasok = new TextField<String>();  
	    pemasok.setName("pemasok");  
	    pemasok.setFieldLabel("pemasok");
	    pemasok.setValidateOnBlur(true);
	    fieldSet.add(pemasok, formData);	  	  

	    final TextField<String> idPemasok = new TextField<String>();  
	    idPemasok.setName("id_pemasok");  
	    idPemasok.setVisible(false);
	    idPemasok.setFieldLabel("id_pemasok");    
	    fieldSet.add(idPemasok, formData);
	    
	    TextField<String> namakpl = new TextField<String>();
	    namakpl.setName("nama_transport");  
	    namakpl.setFieldLabel("Nama Kpl / Tongkang");	    
	    fieldSet.add(namakpl, formData);
	    
	    TextField<String> idTransport = new TextField<String>();
	    idTransport.setName("id_transport");  
	    idTransport.setVisible(false);
	    idTransport.setFieldLabel("id_transport");	    
	    fieldSet.add(idTransport, formData);

	    final TextField<String> noRakor = new TextField<String>();
	    noRakor.setName("no_rakor");  
	    noRakor.setVisible(false);
	    noRakor.setFieldLabel("no_rakor");	    
	    fieldSet.add(noRakor, formData);
	    
	    
	    final TextField<String> tanggal = new TextField<String>();	    
	    tanggal.setName("tanggal");  
	    tanggal.setFieldLabel("Tanggal");
	    tanggal.setVisible(false);	    
	    fieldSet.add(tanggal, formData);
	    

	    
//	    TextField<String> tglTa = new TextField<String>();
	    tglTa = new DateField();
	    tglTa.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
//	    tglTa.setName("time");  
	    tglTa.setFieldLabel("TA");    
	    fieldSet.add(tglTa, formData);

//	    final TextField<String> tglTd = new TextField<String>();
	    tglTd = new DateField();
	    tglTd.setPropertyEditor(new DateTimePropertyEditor("dd/MM/yyyy"));
//	    tglTd.setName("tgl_td");  
	    tglTd.setFieldLabel("TD");    
	    fieldSet.add(tglTd, formData);	    	    


	    TextField<String> tonase = new TextField<String>();
	    tonase.setName("volume");  
	    tonase.setFieldLabel("Volume");	    
	    fieldSet.add(tonase, formData);
	    
	    
	    panel.add(fieldSet);  	     

//	    
	    FieldSet fieldSet2 = new FieldSet();  
//	    fieldSet3.setHeading("Pengajuan Antri");  
	    fieldSet2.setCollapsible(false);

	    FormLayout layout3 = new FormLayout();  
	    layout3.setLabelWidth(160);  
	    fieldSet2.setLayout(layout3);  

	    
//	    CheckBox check1 = new CheckBox();  
//	    check1.setBoxLabel("Yes");  
//	  
//	    CheckBox check2 = new CheckBox();  
//	    check2.setBoxLabel("Pending");  
////	    check2.setValue(true);  
////	  
//	    CheckBox check3 = new CheckBox();  
//	    check3.setBoxLabel("No");  
//	  
//	    CheckBoxGroup checkGroup = new CheckBoxGroup();  
//	    checkGroup.setFieldLabel("Antri");  
//	    checkGroup.add(check1);  
//	    checkGroup.add(check2);  
//	    checkGroup.add(check3);  
//	    fieldSet2.add(checkGroup, formData);
	    	    	   
//	    TextField<String> jetty = new TextField<String>();
//	    jetty.setName("namakpl");  
//	    jetty.setFieldLabel("Jetty");	    
//	    fieldSet2.add(jetty, formData);
	    
	    final TextField<String> pelapor = new TextField<String>();
	    pelapor.setName("pelapor");  
	    pelapor.setFieldLabel("Pelapor");	    
	    fieldSet2.add(pelapor, formData);
	    
	    
	    cboJetty = new ComboBox();  
//	    cboJetty.setName("id_unit_jetty");  
	    cboJetty.setFieldLabel("Jetty / Dermaga");
	    cboJetty.setEmptyText("Select Jetty...");  
	    cboJetty.setDisplayField("kode_jetty");  
	    cboJetty.setWidth(150);  
	    cboJetty.setStore(storeJetty);  
	    cboJetty.setTypeAhead(true);  
	    cboJetty.setTriggerAction(TriggerAction.ALL);
	    cboJetty.addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
	    	@Override
	    	public void selectionChanged(SelectionChangedEvent<ModelData> se) {
	    		// TODO Auto-generated method stub
	    		aktivitasDermaga("master","UNIT","", "");    		
	    	}
		});
	    
	    fieldSet2.add(cboJetty, formData);
	    
	    panel.add(fieldSet2);

	    ContentPanel p = new ContentPanel();
	    p.setHeaderVisible(false);	    
	    p.setButtonAlign(HorizontalAlignment.RIGHT);  
	    p.addButton(new Button("Reset", new SelectionListener<ButtonEvent>() {  
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  
//	        grid.getStore().rejectChanges();  
	      }  
	    }));  
	    bSubmit = new Button("Submit");
	    p.addButton(bSubmit);
	    
//	    p.addButton(bSubmit, new SelectionListener<ButtonEvent>() {
	    bSubmit.addSelectionListener(new SelectionListener<ButtonEvent>() {
	      @Override  
	      public void componentSelected(ButtonEvent ce) {  

	    	  MessageBox.confirm("Info", "Apakah Anda Yakin Ingin Menyimpan Data?",new Listener<MessageBoxEvent>() {

				@Override
				public void handleEvent(MessageBoxEvent be) {
					// TODO Auto-generated method stub
					Button btn = be.getButtonClicked();
					if (btn.getText().equals("Yes")){
					
			    	  	Map mapParam = new FastMap();
			    	  	mapParam.put("no_kedatangan", noAntri.getValue());
			    	  	mapParam.put("id_pengiriman", idPengiriman.getValue());
			    		mapParam.put("no_pengiriman", noPengiriman.getValue());	    		
			    		mapParam.put("no_jadwal", noJadwal.getValue());
			    		mapParam.put("no_rakor", noRakor.getValue());
			    		mapParam.put("id_pemasok", idPemasok.getValue());
			    		mapParam.put("id_unit_jetty", cboJetty.getValue().get("id_unit_jetty").toString());
			    		mapParam.put("tgl_td", tglTd.getRawValue());
			    		mapParam.put("time", tglTa.getRawValue());
			    		mapParam.put("tanggal", tanggal.getValue());
			    		mapParam.put("pelapor", pelapor.getValue());
			    	    mapParam.put("id_pltu", Registry.get("idPltu").toString());
			    		mapParam.put("createby", Registry.get("whoAmI").toString());
			    		mapParam.put("app_access", "WEB");
	
//			    		if (noAntri.getRawValue().equals("")){
			    			mapParam.put("crud", "CREATE");
//			    		}else{
//			    			mapParam.put("crud", "UPDATE");
//			    		}
			    		
			    		service.insertDermagaBb("KEDATANGAN", mapParam,new AsyncCallback<List<Map>>() {
			    			public void onFailure(Throwable caught) {
			    				GWT.log(caught.getMessage(), null);
			    			}
	
			    			public void onSuccess(List<Map> result) {	    				
			    				Info.display("debug ","notification code " + result );
	//		    				noAntri.setVisible(true);	    				
			    				gridKplAntri.mask("load Data ....","x-mask-loading");
			    				aktivitasDermaga("antri","KEDATANGAN","", "");
			    				aktivitasDermaga("pengiriman","PENGIRIMANPORTBYALLPEMASOK","", "");
			    				
			    				MessageBox.alert("Informasi", " " + result, null);
			    			}
			    		});
					}		
		    		//--
				}
			});
	      }  
	    });  

	    panel.add(p);
	    
	    return panel;  
	  }  

	  private Grid createGridAntri(){
		  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
		    column = new ColumnConfig();  
		    column.setId("no_kedatangan");  
		    column.setHeader("No Antri");    
		    column.setWidth(150);    
		    configs.add(column);  
		    
		    column = new ColumnConfig();  
		    column.setId("kode_jetty");  
		    column.setHeader("Jetty");    
		    column.setWidth(150);    
		    configs.add(column);  
		    
		    column = new ColumnConfig();  
		    column.setId("nama_kapal");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	

//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("No Shipment");  
//		    column.setWidth(100);  
//		    configs.add(column);  	  

		    
//		    column = new ColumnConfig();  
//		    column.setId("noKontrak");  
//		    column.setHeader("No Rakor");  
//		    column.setWidth(100);  
//		    configs.add(column);  	  
		    
		    column = new ColumnConfig();  
		    column.setId("time");  
		    column.setHeader("ETA");
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("tgl_td");  
		    column.setHeader("ETD");
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    
		    column = new ColumnConfig();  
		    column.setId("volume");  
		    column.setHeader("Vol");    
		    column.setWidth(100);    
		    configs.add(column);

		    	            		      	    
//		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    storeKplAntri.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
		  
		    gridKplAntri = new Grid(storeKplAntri, cm);  
		    gridKplAntri.getView().setEmptyText("Data Empty");  
		    gridKplAntri.setBorders(false);
		    gridKplAntri.setLoadMask(true);  
		    gridKplAntri.mask("load Data ....","x-mask-loading");
//		    grid.setAutoExpandColumn("pemasok");  
		    gridKplAntri.setBorders(true);  
		    gridKplAntri.addListener(Events.CellClick, new Listener<BaseEvent>() {            
	            public void handleEvent(BaseEvent ge) {
	            	try{
	            		String tgl_ta = gridKplAntri.getSelectionModel().getSelectedItem().get("time");
	            		String tgl_td = gridKplAntri.getSelectionModel().getSelectedItem().get("tgl_td");
	            		String norakor = gridKplAntri.getSelectionModel().getSelectedItem().get("kode_jetty").toString();
//	                	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy"); 
//	                	Date tgl = dateFormat.parse(test);
	                	tglTd.setRawValue(tgl_td);
	                	tglTa.setRawValue(tgl_ta);
	                	cboJetty.setRawValue(norakor);
	                	
//	                	noAntri.setVisible(true);	                	
	                	
	            	}catch (Exception e) {
						// TODO: handle exception
	            		e.getMessage();
					}
	            	
	            	
	            	
	            }
			});

		  
		    return gridKplAntri;  
		  }   
	 
	  
	  private Grid createGridKirim() {  
	  
		    List<ColumnConfig> configs = new ArrayList<ColumnConfig>();  

		    ColumnConfig column = new ColumnConfig();	    	     
		    
		    column = new ColumnConfig();  
		    column.setId("pemasok");  
		    column.setHeader("Pemasok");  
		    column.setWidth(150);  
		    configs.add(column); 

		    
		    column = new ColumnConfig();  
		    column.setId("nama_transport");  
		    column.setHeader("Nama kapal");    
		    column.setWidth(150);    
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("no_pengiriman");  
		    column.setHeader("No Pengiriman");  
		    column.setWidth(100);  
		    configs.add(column);  	
		    
		    
		    column = new ColumnConfig();  
		    column.setId("tgl_ta");  
		    column.setHeader("ETA");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    column = new ColumnConfig();  
		    column.setId("tgl_td");  
		    column.setHeader("ETD");  
		    column.setDateTimeFormat(DateTimeFormat.getFormat("dd/MM/yyyy"));
		    column.setWidth(150);  
		    configs.add(column);  

		    
		    column = new ColumnConfig();  
		    column.setId("volume");  
		    column.setHeader("Vol (Ton)");    
		    column.setWidth(100);    
		    configs.add(column);

		    	            		      
//		    column = new ColumnConfig();  
//		    column.setId("kualitas");  
//		    column.setHeader("Kualitas (kal)");    
//		    column.setWidth(150);  
//		    configs.add(column);		    


		    column = new ColumnConfig();  
		    column.setId("pic");  
		    column.setHeader("CP");  
		    column.setWidth(150);  
		    configs.add(column);  

		    
//		    ListStore<BbMstPembangkitBean> store = new ListStore<BbMstPembangkitBean>();  
		    storeKplKirim.setMonitorChanges(true);  
//		    store.add(TestData.getMstPembangkit());
		  
		    ColumnModel cm = new ColumnModel(configs);  
	  
	    gridKplKirim = new Grid(storeKplKirim, cm);  
	    gridKplKirim.getView().setEmptyText("Data Empty");
	    gridKplKirim.setLoadMask(true);  
	    gridKplKirim.mask("load Data ...","x-mask-loading");
	    gridKplKirim.setBorders(false);  
//	    grid.setAutoExpandColumn("pemasok");  
	    gridKplKirim.setBorders(true);  
	    gridKplKirim.addListener(Events.CellClick, new Listener<BaseEvent>() {            
            public void handleEvent(BaseEvent ge) {
            	try{
            		String tgl_ta = gridKplKirim.getSelectionModel().getSelectedItem().get("tgl_ta");
            		String tgl_td = gridKplKirim.getSelectionModel().getSelectedItem().get("tgl_td");
//            		String norakor = gridKplAntri.getSelectionModel().getSelectedItem().get("kode_jetty").toString();
//                	SimpleDateFormat dateFormat = new SimpleDateFormat("dd/mm/yyyy"); 
//                	Date tgl = dateFormat.parse(test);
                	tglTd.setRawValue(tgl_td);
                	tglTa.setRawValue(tgl_ta);
//                	cboJetty.setRawValue(norakor);
//                	noAntri.setVisible(false);
                	
//                	getdataRakor_kon(norakor);
                	
            	}catch (Exception e) {
					// TODO: handle exception
            		e.getMessage();
				}

             	
            }
		});

	    return gridKplKirim;  
	  }  
	  
	  private void aktivitasDermaga(String module, final String codectrl , String put1,String param1){
		  Map mapParam = new FastMap();
//		     if (codectrl.equals("PENGIRIMANBYALLPEMASOK")){
//		    	 mapParam.put(put1, param1); 
//		     }
		  mapParam.put("id_pltu", Registry.get("idPltu").toString());
		  if (module.equals("pengiriman")){
  		  service.getListPengiriman(codectrl, mapParam,new AsyncCallback<List<Map>>() {
  			public void onFailure(Throwable caught) {
  				GWT.log(caught.getMessage(), null);  			  				
  			}

  			public void onSuccess(List<Map> result) {
  				if (codectrl.equals("PENGIRIMANPORTBYALLPEMASOK")){
  	  				storeKplKirim.removeAll();
  	  			    storeKplKirim.add(ClientModule.setListBaseModelFromListMap(result));
  	  				gridKplKirim.unmask();
  					  				
  				}
  			}
  		});
		  }else if (module.equals("master")){
			  service.getMaster(codectrl, mapParam,new AsyncCallback<List<Map>>() {
		  			public void onFailure(Throwable caught) {
		  				GWT.log(caught.getMessage(), null);
		  			}
		  			public void onSuccess(List<Map> result) {
		  			     if (codectrl.equals("JETTY")){
		  					storeJetty.removeAll();
		  	  			    storeJetty.add(ClientModule.setListBaseModelFromListMap(result));
		  	  			    cboJetty.unmask();
		  			     }
		  			}
		  		});

			  
		  }else if (module.equals("antri")){
			  mapParam.put("id_pltu", Registry.get("idPltu").toString());
			  service.getListDermagaBy(codectrl, mapParam,new AsyncCallback<List<Map>>() {
		  			public void onFailure(Throwable caught) {
		  				GWT.log(caught.getMessage(), null);
		  			}
		  			public void onSuccess(List<Map> result) {
		  			     if (codectrl.equals("KEDATANGAN")){
		  			    	storeKplAntri.removeAll();
		  			    	storeKplAntri.add(ClientModule.setListBaseModelFromListMap(result));
		  			    	gridKplAntri.unmask();
		  			     }
		  			}
		  		});
		  }
	  }
}
